from flask import Blueprint, request
from utils import db, response

wr = Blueprint('writer', __name__)

@wr.route('/api/create', methods=['POST'])
def create():
    '''创建用户'''
    # id = request.json.get("id")
    title = request.json.get("title")
    content = request.json.get("content")
    mood = request.json.get("mood")
    weather = request.json.get("weather")
    tags = request.json.get("tags")
    is_public = request.json.get("is_public")
    user_id = request.json.get("user_id")
    
    sql = "insert into `writer` (title,content,mood,weather,tags,is_public,user_id) values(%s, %s, %s, %s, %s, %s, %s)"
    params = [title,content,mood,weather,tags,is_public,user_id]
    db.insert(sql, params)

    return response.res_200(message="创建成功")
 
# @wr.route('/api/writer', methods=['GET'])
# def writer_list():
#     '''获取用户列表'''
#     sql = "select * from `writer`"
#     params = []
#     result = db.fetch_all(sql, params)
    
#     return response.res_200(message="已获取全部列表", data=result)